package yunhe.view;

import java.awt.Graphics;

import javax.swing.JPanel;

import yunhe.entity.Food;
import yunhe.entity.Ground;
import yunhe.entity.Snake;

/**
 * 操作界面
 * 
 * @author 六六大欢
 *
 */
public class GamePanel extends JPanel {
	private Snake snake;
	private Food food;
	private Ground ground;

	public void display(Snake snake, Food food, Ground ground) {
		System.out.println("面板显示");
		this.snake = snake;
		this.food = food;
		this.ground = ground;
		//重复展示
		repaint();
	}
	/**
	 * 重写展示的方法
	 */
	@Override
	protected void paintComponent(Graphics g) {
		//清除轨迹
		super.paintComponent(g);
		
		if (snake != null && food != null && ground != null){
			snake.showMe(g);
		    food.showMe(g);
		    ground.showMe(g);
		}
			
	}

}
